using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
using System.Globalization;

namespace Scenario.Security
{
	/// <summary>
	/// Descrizione di riepilogo per Class1.
	/// </summary>
	public class DataValidator
	{	
		//*********************************************************************
		//Match italian telephone number with prefix followed by "/", "-" or blank and number. 
		//Usefull with numeric keybord! 
		//*********************************************************************
		public const string VALID_ITALIAN_TELEPHON = @"^([0-9]*\-?\ ?\/?[0-9]*)$";

		//*********************************************************************
		//Validates a Italian mobile phone number with (or without) the International code
		//*********************************************************************
		public const string VALID_ITALIAN_MOBILETELEPHON = @"^([+]39)?((38[{8,9}|0])|(34[{7-9}|0])|(36[6|8|0])|(33[{3-9}|0])|(32[{8,9}]))([\d]{7})$";

		//*********************************************************************
		//This pattern match italian fiscal code (codice fiscale). 
		//*********************************************************************
		public const string VALID_ITALIAN_FISCALCODE = @"^[A-Za-z]{6}[0-9]{2}[A-Za-z]{1}[0-9]{2}[A-Za-z]{1}[0-9]{3}[A-Za-z]{1}$";
		
		//*********************************************************************
		//This simple regexp should match any possible italian address entry and doesn't 
		//match NULL entries (good if address is required). Should work well for any other 
		//address (it's been verified against 250 addresses from most european countries, 
		//usa and australia. 
		//*********************************************************************
		public const string VALID_ITALIAN_ADDRESS = @"^[a-zA-Z0-9ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ\.\,\-\/\']+[a-zA-Z0-9ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ\.\,\-\/\' ]+$";
		
		//*********************************************************************
		// matches DD/MM/Y or DD/MM/YYYY or D/M/Y or DD/M/YYYY Leap years treated. 
		//(Italian style with tomato) Years 0-9 equal years 2000 to 2009 for leap years
		//*********************************************************************
		public const string VALID_ITALIAN_DATE = @"^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00|[048])))$";
		
		//*********************************************************************
		//String Whithout special caracters
		//*********************************************************************
		private const string REPLACE_FROM_STRING = @"[^\\.!?""',\-\w\s@]";
		public const string VALID_STRING = @"^[a-zA-Z0-9_\s-]+$";


		//*********************************************************************
		//Simple url Width or Widthout http://
		//*********************************************************************
		public const string VALID_SIMPLE_URL = @"(?<http>(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)";

		//*********************************************************************
		//Validates 1 or more email addresses. Email addresses can be delimited with either 
		//comma or semicolon. White space is allowed after delimiter, but not necessary. 
		//I needed this to allow my users to specify multiple email addresses if they choose to do so.
		//*********************************************************************
		public const string VALID_MULTIPLE_EMAIL = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*";
		public const string VALID_SIMPLE_EMAIL = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";

		//*********************************************************************
		// Italian Partita Iva
		//*********************************************************************
		public const string VALID_ITALIAN_PIVA = @"\d{11}";

		
		//*********************************************************************
		// Data Conversion 
		//*********************************************************************
		public static bool DateValidator(string Data)
		{
			try
			{
				Convert.ToDateTime(Data);
				return true;
			}
			catch
			{
				return false;
			}

		}

		//*********************************************************************
		//
		// <summary>
		// Validates the input text using a Regular Expression and replaces any input expression
		// characters with empty string.Removes any characters not in [a-zA-Z0-9_]. 
		// <summary>
		// <remarks>
		// For a good reference on Regular Expressions, please see
		//	 - http://regexlib.com
		//	 - http://py-howto.sourceforge.net/regex/regex.html
		// </remarks>
		// <param name="inputText">The text to validate.</param>
		// <returns>Sanitized string</returns>
		//
		//*********************************************************************

		public static string CleanStringRegex(string inputText)
		{
			RegexOptions options = RegexOptions.IgnoreCase;
			return ReplaceRegex(inputText,REPLACE_FROM_STRING,options);
		}

		//*********************************************************************
		//
		// <summary>
		// Removes designated characters from an input string input text using a Regular Expression.
		// </summary>
		// <remarks>
		// For a good reference on Regular Expressions, please see
		//	 - http://regexlib.com
		//	 - http://py-howto.sourceforge.net/regex/regex.html
		// </remarks>
		// <param name="inputText">The text to clean.</param>
		// <param name="regularExpression">The regular expression</param>
		// <returns>Sanitized string.</returns>
		//
		//*********************************************************************

		private static string ReplaceRegex(string inputText, string regularExpression, RegexOptions options)
		{
			Regex regex = new Regex(regularExpression,options);
			return regex.Replace(inputText,"");
		}

		//*************************************************************************
		// transform a string witch contains an xml file width special characters
		// in a string widthout special characters and unicode codes instead.
		//*************************************************************************
		public string XmlStringWidthoutSpecials(string XMLString)
		{
			if (XMLString==null || XMLString.Length<=0)
				return "NO STRING";

			try
			{
				System.Xml.XmlDocument Doc = new System.Xml.XmlDocument();
				Doc.LoadXml(XMLString);

				System.Xml.XmlNode nodeList;
				nodeList = Doc.FirstChild;

				AnalizeNodeList(nodeList);

				return nodeList.ToString();

			}
			catch
			{
				return "NO XML STRING";
			}
		}

		//*************************************************************************
		// Analize Node and Subnodes in an xml string and remove special characters
		//*************************************************************************
		public void AnalizeNodeList(System.Xml.XmlNode nodeList)
		{

			System.Xml.XmlNode First;

			// explore Node Attributes
			for ( int i=0; i<nodeList.Attributes.Count; i++)
			{
				First= nodeList.Attributes.Item(i);

				// remove special carcters
				RemoveSpecial(First.ToString());
			}

			// Exlore node value
			if (nodeList.ChildNodes.Count>0)
			{
				for ( int i=0; i<nodeList.ChildNodes.Count; i++)
				{
					System.Xml.XmlNode node;
					node = nodeList.ChildNodes[i];
					AnalizeNodeList(node);
				}
			}
			else
			{
				RemoveSpecial(nodeList.InnerText);
			}
		}

		public static string RemoveSpecial(string string2validtate)
		{
			string StringOut = string2validtate;

			// remove & caracter
			StringOut = StringOut.Replace("&","&#38;");
			StringOut = StringOut.Replace("&#38;#","&");
			
			// remove others special characters

			StringOut = StringOut.Replace("ǿ","&#511;");
			StringOut = StringOut.Replace("Ǿ","&#510;");
			StringOut = StringOut.Replace("ǽ ","&509;");
			StringOut = StringOut.Replace("Ǽ","&#508;");
			StringOut = StringOut.Replace("ǻ","&#507;");
			StringOut = StringOut.Replace("Ǻ","&#506;");
			StringOut = StringOut.Replace("ǜ","&#476;");
			StringOut = StringOut.Replace("Ǜ","&#475;");
			StringOut = StringOut.Replace("ǚ","&#474;");
			StringOut = StringOut.Replace("Ǚ","&#473;");
			StringOut = StringOut.Replace("ǘ","&#472;");
			StringOut = StringOut.Replace("Ǘ","&#471;");
			StringOut = StringOut.Replace("ǖ","&#470;");
			StringOut = StringOut.Replace("Ǖ","&#469;");
			StringOut = StringOut.Replace("ǔ","&#468;");
			StringOut = StringOut.Replace("Ǔ","&#467;");
			StringOut = StringOut.Replace("ǒ","&#466;");
			StringOut = StringOut.Replace("Ǒ","&#465;");
			StringOut = StringOut.Replace("ǐ","&#464;");
			StringOut = StringOut.Replace("Ǐ","&#463;");
			StringOut = StringOut.Replace("ǎ","&#462;");
			StringOut = StringOut.Replace("Ǎ","&#461;");
			StringOut = StringOut.Replace("ư","&#432;");
			StringOut = StringOut.Replace("Ư","&#431;");
			StringOut = StringOut.Replace("ơ","&#417;");
			StringOut = StringOut.Replace("Ơ","&#416;");
			StringOut = StringOut.Replace("ƒ","&#402;");
			StringOut = StringOut.Replace("Ə","&#399;");
			StringOut = StringOut.Replace("ſ","&#383;");
			StringOut = StringOut.Replace("ž","&#382;");
			StringOut = StringOut.Replace("Ž","&#381;");
			StringOut = StringOut.Replace("ż","&#380;");
			StringOut = StringOut.Replace("Ż","&#379;");
			StringOut = StringOut.Replace("ź","&#378;");
			StringOut = StringOut.Replace("Ź","&#377;");
			StringOut = StringOut.Replace("Ÿ","&#376;");
			StringOut = StringOut.Replace("ŷ","&#375;");
			StringOut = StringOut.Replace("Ŷ","&#374;");
			StringOut = StringOut.Replace("ŵ","&#373;");
			StringOut = StringOut.Replace("Ŵ","&#372;");
			StringOut = StringOut.Replace("ų","&#371;");
			StringOut = StringOut.Replace("Ų","&#370;");
			StringOut = StringOut.Replace("ű","&#369;");
			StringOut = StringOut.Replace("Ű","&#368;");
			StringOut = StringOut.Replace("ů","&#367;");
			StringOut = StringOut.Replace("Ů","&#366;");
			StringOut = StringOut.Replace("ŭ","&#365;");
			StringOut = StringOut.Replace("Ŭ","&#364;");
			StringOut = StringOut.Replace("ū","&#363;");
			StringOut = StringOut.Replace("Ū","&#362;");
			StringOut = StringOut.Replace("ũ","&#361;");
			StringOut = StringOut.Replace("Ũ","&#360;");
			StringOut = StringOut.Replace("ŧ","&#359;");
			StringOut = StringOut.Replace("Ŧ","&#358;");
			StringOut = StringOut.Replace("ť","&#357;");
			StringOut = StringOut.Replace("Ť","&#356;");
			StringOut = StringOut.Replace("ţ","&#355;");
			StringOut = StringOut.Replace("Ţ","&#354;");
			StringOut = StringOut.Replace("š","&#353;");
			StringOut = StringOut.Replace("Š","&#352;");
			StringOut = StringOut.Replace("ş","&#351;");
			StringOut = StringOut.Replace("Ş","&#350;");
			StringOut = StringOut.Replace("ŝ","&#349;");
			StringOut = StringOut.Replace("Ŝ","&#348;");
			StringOut = StringOut.Replace("ś","&#347;");
			StringOut = StringOut.Replace("Ś","&#346;");
			StringOut = StringOut.Replace("ř","&#345;");
			StringOut = StringOut.Replace("Ř","&#344;");
			StringOut = StringOut.Replace("ŗ","&#343;");
			StringOut = StringOut.Replace("Ŗ","&#342;");
			StringOut = StringOut.Replace("ŕ","&#341;");
			StringOut = StringOut.Replace("Ŕ","&#340;");
			StringOut = StringOut.Replace("œ","&#339;");
			StringOut = StringOut.Replace("Œ","&#338;");
			StringOut = StringOut.Replace("ő","&#337;");
			StringOut = StringOut.Replace("Ő","&#336;");
			StringOut = StringOut.Replace("ŏ","&#335;");
			StringOut = StringOut.Replace("Ŏ","&#334;");
			StringOut = StringOut.Replace("ō","&#333;");
			StringOut = StringOut.Replace("Ō","&#332;");
			StringOut = StringOut.Replace("ŋ","&#331;");
			StringOut = StringOut.Replace("Ŋ","&#330;");
			StringOut = StringOut.Replace("ŉ","&#329;");
			StringOut = StringOut.Replace("ň","&#328;");
			StringOut = StringOut.Replace("Ň","&#327;");
			StringOut = StringOut.Replace("ņ","&#326;");
			StringOut = StringOut.Replace("Ņ","&#325;");
			StringOut = StringOut.Replace("ń","&#324;");
			StringOut = StringOut.Replace("Ń","&#323;");
			StringOut = StringOut.Replace("ł","&#322;");
			StringOut = StringOut.Replace("Ł","&#321;");
			StringOut = StringOut.Replace("ŀ","&#320;");
			StringOut = StringOut.Replace("Ŀ","&#319;");
			StringOut = StringOut.Replace("ľ","&#318;");
			StringOut = StringOut.Replace("Ľ","&#317;");
			StringOut = StringOut.Replace("ļ","&#316;");
			StringOut = StringOut.Replace("Ļ","&#315;");
			StringOut = StringOut.Replace("ĺ","&#314;");
			StringOut = StringOut.Replace("Ĺ","&#313;");
			StringOut = StringOut.Replace("ĸ","&#312;");
			StringOut = StringOut.Replace("ķ","&#311;");
			StringOut = StringOut.Replace("Ķ","&#310;");
			StringOut = StringOut.Replace("ĵ","&#309;");
			StringOut = StringOut.Replace("Ĵ","&#308;");
			StringOut = StringOut.Replace("ĳ","&#307;");
			StringOut = StringOut.Replace("Ĳ","&#306;");
			StringOut = StringOut.Replace("ı","&#305;");
			StringOut = StringOut.Replace("İ","&#304;");
			StringOut = StringOut.Replace("į","&#303;");
			StringOut = StringOut.Replace("Į","&#302;");
			StringOut = StringOut.Replace("ĭ","&#301;");
			StringOut = StringOut.Replace("Ĭ","&#300;");
			StringOut = StringOut.Replace("ī","&#299;");
			StringOut = StringOut.Replace("Ī","&#298;");
			StringOut = StringOut.Replace("ĩ","&#297;");
			StringOut = StringOut.Replace("Ĩ","&#296;");
			StringOut = StringOut.Replace("ħ","&#295;");
			StringOut = StringOut.Replace("Ħ","&#294;");
			StringOut = StringOut.Replace("ĥ","&#293;");
			StringOut = StringOut.Replace("Ĥ","&#292;");
			StringOut = StringOut.Replace("ģ","&#291;");
			StringOut = StringOut.Replace("Ģ","&#290;");
			StringOut = StringOut.Replace("ġ","&#289;");
			StringOut = StringOut.Replace("Ġ","&#288;");
			StringOut = StringOut.Replace("ğ","&#287;");
			StringOut = StringOut.Replace("Ğ","&#286;");
			StringOut = StringOut.Replace("ĝ","&#285;");
			StringOut = StringOut.Replace("Ĝ","&#284;");
			StringOut = StringOut.Replace("ě","&#283;");
			StringOut = StringOut.Replace("Ě","&#282;");
			StringOut = StringOut.Replace("ę","&#281;");
			StringOut = StringOut.Replace("Ę","&#280;");
			StringOut = StringOut.Replace("ė","&#279;");
			StringOut = StringOut.Replace("Ė","&#278;");
			StringOut = StringOut.Replace("ĕ","&#277;");
			StringOut = StringOut.Replace("Ĕ","&#276;");
			StringOut = StringOut.Replace("ē","&#275;");
			StringOut = StringOut.Replace("Ē","&#274;");
			StringOut = StringOut.Replace("đ","&#273;");
			StringOut = StringOut.Replace("Đ","&#272;");
			StringOut = StringOut.Replace("ď","&#271;");
			StringOut = StringOut.Replace("Ď","&#270;");
			StringOut = StringOut.Replace("č","&#269;");
			StringOut = StringOut.Replace("Č","&#268;");
			StringOut = StringOut.Replace("ċ","&#267;");
			StringOut = StringOut.Replace("Ċ","&#266;");
			StringOut = StringOut.Replace("ĉ","&#265;");
			StringOut = StringOut.Replace("Ĉ","&#264;");
			StringOut = StringOut.Replace("ć","&#263;");
			StringOut = StringOut.Replace("Ć","&#262;");
			StringOut = StringOut.Replace("ą","&#261;");
			StringOut = StringOut.Replace("Ą","&#260;");
			StringOut = StringOut.Replace("ă","&#259;");
			StringOut = StringOut.Replace("Ă","&#258;");
			StringOut = StringOut.Replace("ā","&#257;");
			StringOut = StringOut.Replace("Ā","&#256;");
			StringOut = StringOut.Replace("ÿ","&#255;");
			StringOut = StringOut.Replace("þ","&#254;");
			StringOut = StringOut.Replace("ý","&#253;");
			StringOut = StringOut.Replace("ü","&#252;");
			StringOut = StringOut.Replace("û","&#251;");
			StringOut = StringOut.Replace("ú","&#250;");
			StringOut = StringOut.Replace("ù","&#249;");
			StringOut = StringOut.Replace("ø","&#248;");
			StringOut = StringOut.Replace("÷","&#247;");
			StringOut = StringOut.Replace("ö","&#246;");
			StringOut = StringOut.Replace("õ","&#245;");
			StringOut = StringOut.Replace("ô","&#244;");
			StringOut = StringOut.Replace("ó","&#243;");
			StringOut = StringOut.Replace("ò","&#242;");
			StringOut = StringOut.Replace("ñ","&#241;");
			StringOut = StringOut.Replace("ð","&#240;");
			StringOut = StringOut.Replace("ï","&#239;");
			StringOut = StringOut.Replace("î","&#238;");
			StringOut = StringOut.Replace("í","&#237;");
			StringOut = StringOut.Replace("ì","&#236;");
			StringOut = StringOut.Replace("ë","&#235;");
			StringOut = StringOut.Replace("ê","&#234;");
			StringOut = StringOut.Replace("é","&#233;");
			StringOut = StringOut.Replace("è","&#232;");
			StringOut = StringOut.Replace("ç","&#231;");
			StringOut = StringOut.Replace("æ","&#230;");
			StringOut = StringOut.Replace("å","&#229;");
			StringOut = StringOut.Replace("ä","&#228;");
			StringOut = StringOut.Replace("ã","&#227;");
			StringOut = StringOut.Replace("â","&#226;");
			StringOut = StringOut.Replace("á","&#225;");
			StringOut = StringOut.Replace("à","&#224;");
			StringOut = StringOut.Replace("ß","&#223;");
			StringOut = StringOut.Replace("Þ","&#222;");
			StringOut = StringOut.Replace("Ý","&#221;");
			StringOut = StringOut.Replace("Ü","&#220;");
			StringOut = StringOut.Replace("Û","&#219;");
			StringOut = StringOut.Replace("Ú","&#218;");
			StringOut = StringOut.Replace("Ù","&#217;");
			StringOut = StringOut.Replace("Ø","&#216;");
			StringOut = StringOut.Replace("×","&#215;");
			StringOut = StringOut.Replace("Ö","&#214;");
			StringOut = StringOut.Replace("Õ","&#213;");
			StringOut = StringOut.Replace("Ô","&#212;");
			StringOut = StringOut.Replace("Ó","&#211;");
			StringOut = StringOut.Replace("Ò","&#210;");
			StringOut = StringOut.Replace("Ñ","&#209;");
			StringOut = StringOut.Replace("Ð","&#208;");
			StringOut = StringOut.Replace("Ï","&#207;");
			StringOut = StringOut.Replace("Î","&#206;");
			StringOut = StringOut.Replace("Í","&#205;");
			StringOut = StringOut.Replace("Ì","&#204;");
			StringOut = StringOut.Replace("Ë","&#203;");
			StringOut = StringOut.Replace("Ê","&#202;");
			StringOut = StringOut.Replace("É","&#201;");
			StringOut = StringOut.Replace("È","&#200;");
			StringOut = StringOut.Replace("Ç","&#199;");
			StringOut = StringOut.Replace("Æ","&#198;");
			StringOut = StringOut.Replace("Å","&#197;");
			StringOut = StringOut.Replace("Ä","&#196;");
			StringOut = StringOut.Replace("Ã","&#195;");
			StringOut = StringOut.Replace("Â","&#194;");
			StringOut = StringOut.Replace("Á","&#193;");
			StringOut = StringOut.Replace("À","&#192;");
			StringOut = StringOut.Replace("¿","&#191;");
			StringOut = StringOut.Replace("¾","&#190;");
			StringOut = StringOut.Replace("½","&#189;");
			StringOut = StringOut.Replace("¼","&#188;");
			StringOut = StringOut.Replace("»","&#187;");
			StringOut = StringOut.Replace("º","&#186;");
			StringOut = StringOut.Replace("¹","&#185;");
			StringOut = StringOut.Replace("¸","&#184;");
			StringOut = StringOut.Replace("·","&#183;");
			StringOut = StringOut.Replace("¶","&#182;");
			StringOut = StringOut.Replace("µ","&#181;");
			StringOut = StringOut.Replace("´","&#180;");
			StringOut = StringOut.Replace("³","&#179;");
			StringOut = StringOut.Replace("²","&#178;");
			StringOut = StringOut.Replace("±","&#177;");
			StringOut = StringOut.Replace("°","&#176;");
			StringOut = StringOut.Replace("¯","&#175;");
			StringOut = StringOut.Replace("®","&#174;");
			StringOut = StringOut.Replace("­","&#173;");
			StringOut = StringOut.Replace("¬","&#172;");
			StringOut = StringOut.Replace("«","&#171;");
			StringOut = StringOut.Replace("ª","&#170;");
			StringOut = StringOut.Replace("©","&#169;");
			StringOut = StringOut.Replace("¨","&#168;");
			StringOut = StringOut.Replace("§","&#167;");
			StringOut = StringOut.Replace("¦","&#166;");
			StringOut = StringOut.Replace("¥","&#165;");
			StringOut = StringOut.Replace("¤","&#164;");
			StringOut = StringOut.Replace("£","&#163;");
			StringOut = StringOut.Replace("¢","&#162;");
			StringOut = StringOut.Replace("¡","&#161;");
			StringOut = StringOut.Replace("Ÿ","&#159;");
			StringOut = StringOut.Replace("ž","&#158;");
			StringOut = StringOut.Replace("œ","&#156;");
			StringOut = StringOut.Replace("›","&#155;");
			StringOut = StringOut.Replace("š","&#154;");
			StringOut = StringOut.Replace("™","&#153;");
			StringOut = StringOut.Replace("˜","&#152;");
			StringOut = StringOut.Replace("—","&#151;");
			StringOut = StringOut.Replace("–","&#150;");
			StringOut = StringOut.Replace("•","&#149;");
			StringOut = StringOut.Replace("”","&#148;");
			StringOut = StringOut.Replace("“","&#147;");
			StringOut = StringOut.Replace("’","&#146;");
			StringOut = StringOut.Replace("‘","&#145;");
			StringOut = StringOut.Replace("Ž","&#142;");
			StringOut = StringOut.Replace("Œ","&#140;");
			StringOut = StringOut.Replace("‹","&#139;");
			StringOut = StringOut.Replace("Š","&#138;");
			StringOut = StringOut.Replace("‰","&#137;");
			StringOut = StringOut.Replace("ˆ","&#136;");
			StringOut = StringOut.Replace("‡","&#135;");
			StringOut = StringOut.Replace("†","&#134;");
			StringOut = StringOut.Replace("…","&#133;");
			StringOut = StringOut.Replace("„","&#132;");
			StringOut = StringOut.Replace("ƒ","&#131;");

			
			return StringOut;
		}

		public static string RemoveAccent(string string2validate)
		{
			string stringOut = string2validate;

			stringOut = stringOut.Replace("&","And");

			stringOut = stringOut.Replace("<","Min");
			stringOut = stringOut.Replace(">","Mag");

			stringOut = stringOut.Replace("à","a'");
			stringOut = stringOut.Replace("á","a'");
			stringOut = stringOut.Replace("è","e'");
			stringOut = stringOut.Replace("é","e'");
			stringOut = stringOut.Replace("ì","i'");
			stringOut = stringOut.Replace("í","i'");
			stringOut = stringOut.Replace("ò","o'");
			stringOut = stringOut.Replace("ó","o'");
			stringOut = stringOut.Replace("ù","u'");
			stringOut = stringOut.Replace("ú","u'");

			return stringOut;
		}


		//*************************************************************************
		// Get format IFormatProvider to correct convert string from xml to double Euro numbers
		//*************************************************************************
		public static NumberFormatInfo GetEuroProvider()
		{
			NumberFormatInfo provider = new NumberFormatInfo();
			provider.NumberDecimalSeparator = ",";
			provider.NumberGroupSeparator = ".";
			provider.NumberGroupSizes = new int[ ] { 3 };
			provider.CurrencyDecimalDigits = 2;
			provider.CurrencySymbol = "Sc";

			return provider;
		}

		//*************************************************************************
		// Get format IFormatProvider to correct convert string from xml to double Euro numbers
		//*************************************************************************
		public static NumberFormatInfo GetDoubleProvider(int Ndec)
		{
			NumberFormatInfo provider = new NumberFormatInfo();
			provider.NumberDecimalSeparator = ",";
			provider.CurrencyDecimalDigits = Ndec;

			return provider;
		}



	}
}
